﻿Public Class Rdescuento

    Public Shared Function SeleccionarTodo(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean) As List(Of Edescuento)
        Dim descuentos As List(Of Edescuento) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                descuentos = Ddescuento.SeleccionarTodo(descEmpresa)
                If descuentos Is Nothing Then descuentos = New List(Of Edescuento)
                If DisplaySelect Then descuentos.Insert(0, New Edescuento("00", "-- SELECCIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using
        Return descuentos
    End Function
    Public Shared Function SeleccionarTodoxEstado(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean) As List(Of Edescuento)
        Dim descuentos As List(Of Edescuento) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                descuentos = Ddescuento.SeleccionarTodoXEstado(descEmpresa)
                If descuentos Is Nothing Then descuentos = New List(Of Edescuento)
                If DisplaySelect Then descuentos.Insert(0, New Edescuento("00", "-- SELECCIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return descuentos
    End Function
    
    Public Shared Function SeleccionarDescuentoxTipo(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean, ByVal idProyecto As Int32, ByVal idTpoDescuento As Int32) As List(Of Edescuento)
        Dim descuentos As List(Of Edescuento) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                descuentos = Ddescuento.SeleccionarDescuentoxTipo(descEmpresa, idProyecto, idTpoDescuento)
                If descuentos Is Nothing Then descuentos = New List(Of Edescuento)
                If DisplaySelect Then descuentos.Insert(0, New Edescuento("00", "-- SELECCIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return descuentos
    End Function
    Public Shared Function SeleccionarTodoXId(ByVal descEmpresa As String, ByVal pIdDscto As Int32) As Edescuento
        Dim descuento As Edescuento = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                descuento = Ddescuento.SeleccionarTodoXId(descEmpresa, pIdDscto)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return descuento
    End Function
    Public Shared Function SeleccionarTodoXIdProyecto(ByVal descEmpresa As String, ByVal pIdDscto As Int32, ByVal idProyecto As Int32) As Edescuento
        Dim descuento As Edescuento = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                descuento = Ddescuento.SeleccionarTodoXIdProyecto(descEmpresa, pIdDscto, idProyecto)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return descuento
    End Function
    Public Shared Function SeleccionarProyecto(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean) As List(Of Eproyecto)
        Dim proyectos As List(Of Eproyecto) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                proyectos = Ddescuento.SeleccionarProyecto(descEmpresa)
                If proyectos Is Nothing Then proyectos = New List(Of Eproyecto)
                If DisplaySelect Then proyectos.Insert(0, New Eproyecto("00", "-- SELECCIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using
        Return proyectos
    End Function
    Public Shared Function consultaDescuento(ByVal descEmpresa As String, ByVal pDescuento As Edescuento) As List(Of Edescuento)
        Dim descuentoDetalles As List(Of Edescuento) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                descuentoDetalles = Ddescuento.consultaDescuento(descEmpresa, pDescuento)
                If descuentoDetalles Is Nothing Then descuentoDetalles = New List(Of Edescuento)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return descuentoDetalles
    End Function
    Public Shared Function SeleccionarTpoDescuento(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean) As List(Of Edescuento)
        Dim tpoDescuentos As List(Of Edescuento) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                tpoDescuentos = Ddescuento.SeleccionarTpoDescuento(descEmpresa)
                If tpoDescuentos Is Nothing Then tpoDescuentos = New List(Of Edescuento)
                If DisplaySelect Then tpoDescuentos.Insert(0, New Edescuento("00", "-- SELECCIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using
        Return tpoDescuentos
    End Function

    Public Shared Function Añadir(ByVal descEmpresa As String, ByVal pDescuento As Edescuento) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = Ddescuento.Añadir(descEmpresa, pDescuento)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function Editar(ByVal descEmpresa As String, ByVal pDescuento As Edescuento) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = Ddescuento.Editar(descEmpresa, pDescuento)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function
    Public Shared Function Eliminar(ByVal descEmpresa As String, ByVal pDescuento As Edescuento) As Boolean
        Dim resultado As Boolean = False

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                resultado = Ddescuento.Eliminar(descEmpresa, pDescuento)
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return resultado
    End Function

    Public Shared Function Buscar(ByVal descEmpresa As String, ByVal DisplaySelect As Boolean, ByVal pDescuento As Edescuento) As List(Of Edescuento)
        Dim descuentos As List(Of Edescuento) = Nothing

        Dim options As New TransactionOptions
        options.IsolationLevel = Transactions.IsolationLevel.ReadCommitted
        options.Timeout = New TimeSpan(0, 2, 0)

        Using scope As New TransactionScope(TransactionScopeOption.Required, options)
            Try
                descuentos = Ddescuento.Buscar(descEmpresa, pDescuento)
                If descuentos Is Nothing Then descuentos = New List(Of Edescuento)
                If DisplaySelect Then descuentos.Insert(0, New Edescuento("00", "-- SELECCIONAR --"))
                scope.Complete()
            Catch ex As Exception
                Throw
            End Try
        End Using

        Return descuentos
    End Function

End Class
